write memory efficient python code

visit shbcf.ru